//
//  VehicleListViewController.m
//  Runone
//
//  Created by runone02 on 16/10/25.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "VehicleListViewController.h"
#import "InVehicleModel.h"
#import "InVehicleDetailViewController.h"
#import "AppConstants.h"

@interface VehicleListViewController ()

@end

static NSString *cellID = @"inVehicleCell";
@implementation VehicleListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configTableView];
    [self.tableView reloadData];
}

- (void)configTableView {
    self.tableView.separatorStyle             = UITableViewCellSeparatorStyleNone;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.tableView.scrollEnabled              = YES;
    self.tableView.bounces                    = NO;
    self.tableView.contentInset = UIEdgeInsetsMake(108, 0, 0, 0);
    
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return _dataArr.count;;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
    }
    InVehicleModel *model = _dataArr[indexPath.row];
    cell.textLabel.text  = model.VehicleNo;
    cell.accessoryType   = UITableViewCellAccessoryDisclosureIndicator;
    if (_dataArr.count == 0) {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    InVehicleDetailViewController *vc = [[InVehicleDetailViewController alloc] init];
    vc.listModel = _dataArr[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}
@end
